home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SNNSV32.ZIP / SNNSv3.2 / xgui / sources / ui_key.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-25  |  39.7 KB  |  1,371 lines

  1. /*****************************************************************************
  2.   FILE           : ui_key.c
  3.   SHORTNAME      : key.h
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        :
  7.   NOTES          :
  8.  
  9.   AUTHOR         : Tilman Sommer
  10.   DATE           : 6.6.1990
  11.  
  12.   CHANGED BY     :
  13.   IDENTIFICATION : @(#)ui_key.c    1.11 3/2/94
  14.   SCCS VERSION   : 1.11
  15.   LAST CHANGE    : 3/2/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.              
  19. ******************************************************************************/
  20.  
  21. #include <stdio.h>
  22.  
  23. #include "ui.h"
  24.  
  25. #include <X11/Xaw/SimpleMenu.h>
  26. #include <X11/Xaw/SmeBSB.h>
  27. #include <X11/Xaw/SmeLine.h>
  28. #include <X11/keysym.h>
  29.  
  30. #include "ui_action.h"
  31. #include "ui_utilP.h"
  32. #include "ui_status.h" 
  33. #include "ui_event.h"
  34.  
  35. #include "glob_typ.h"    /*  Kernel constant and type definitions  */
  36. #include "kr_ui.h"    /*  Kernel interface functions    */
  37.  
  38. #include "ui_mainP.h"
  39. #include "ui_confirmer.h"
  40. #include "ui_display.h"
  41. #include "ui_xGraphic.h"
  42. #include "ui_selection.h"
  43. #include "ui_netUpdate.h"
  44. #include "ui_info.h"
  45.  
  46. #include "ui_key.ph"
  47.  
  48.  
  49. /*****************************************************************************
  50.   FUNCTION : ui_can_setBusyCursor   (NOT IMPLEMENTED)
  51.  
  52.   PURPOSE  :
  53.   RETURNS  : void
  54.   NOTES    : 
  55.  
  56.   UPDATE   : 
  57. ******************************************************************************/
  58.  
  59. static void ui_can_setBusyCursor(void) /* not implemented */
  60.  
  61. {}
  62.  
  63.  
  64. /*****************************************************************************
  65.   FUNCTION : ui_can_setNormalCursor   (NOT IMPLEMENTED)
  66.  
  67.   PURPOSE  :
  68.   RETURNS  :
  69.   NOTES    : 
  70.  
  71.   UPDATE   : 
  72. ******************************************************************************/
  73.  
  74. static void ui_can_setNormalCursor(void) /* not implemented */
  75.  
  76. {}
  77.  
  78.  
  79. /*****************************************************************************
  80.   FUNCTION : ui_key_init()
  81.  
  82.   PURPOSE  :
  83.   RETURNS  : void
  84.   NOTES    : It would be simpler to use normal aggregate initialization, but
  85.              this version is independent from the assignment of the STATE
  86.          constants!
  87.  
  88.   UPDATE   : 20.9.1990
  89. ******************************************************************************/
  90.  
  91. void ui_key_init (void)
  92.  
  93. {
  94.     ui_commands[UI_START_STATE][0] = "Units     ~";
  95.     ui_commands[UI_START_STATE][1] = "Links     ~";
  96.     ui_commands[UI_START_STATE][2] = "Sites     ~";
  97.     ui_commands[UI_START_STATE][3] = "Graphics  ~";
  98.     ui_commands[UI_START_STATE][4] = "Mode      ~";
  99.     ui_commands[UI_START_STATE][5] = "Flags     ~";
  100.     ui_commands[UI_START_STATE][6] = "Help";
  101.  
  102.     ui_commands[UI_STATE_MODE][0] = "Units";
  103.     ui_commands[UI_STATE_MODE][1] = "Links";
  104.     ui_commands[UI_STATE_MODE][2] = "Quit";
  105.     ui_commands[UI_STATE_MODE][3] = "Help";
  106.  
  107.     ui_commands[UI_STATE_UNITS][0] = "Set       ~";
  108.     ui_commands[UI_STATE_UNITS][1] = "Copy      ~";
  109.     ui_commands[UI_STATE_UNITS][2] = "Delete";
  110.     ui_commands[UI_STATE_UNITS][3] = "Insert    ~";
  111.     ui_commands[UI_STATE_UNITS][4] = "Move      T";
  112.     ui_commands[UI_STATE_UNITS][5] = "Freeze";
  113.     ui_commands[UI_STATE_UNITS][6] = "Unfreeze";
  114.     ui_commands[UI_STATE_UNITS][7] = "Return";
  115.     ui_commands[UI_STATE_UNITS][8] = "Quit";
  116.     ui_commands[UI_STATE_UNITS][9] = "Help";
  117.     ui_commands[UI_STATE_UNITS][10] ="3D         ~";
  118.  
  119.     ui_commands[UI_STATE_UNITS_INSERT][0] = "Default unit  !";
  120.     ui_commands[UI_STATE_UNITS_INSERT][1] = "Target unit   !";
  121.     ui_commands[UI_STATE_UNITS_INSERT][2] = "F-type unit   !";
  122.     ui_commands[UI_STATE_UNITS_INSERT][3] = "Return";
  123.     ui_commands[UI_STATE_UNITS_INSERT][4] = "Quit";
  124.     ui_commands[UI_STATE_UNITS_INSERT][5] = "Help";
  125.  
  126.     ui_commands[UI_STATE_LINKS][0] = "Set";
  127.     ui_commands[UI_STATE_LINKS][1] = "Copy    ~";
  128.     ui_commands[UI_STATE_LINKS][2] = "Delete  ~";
  129.     ui_commands[UI_STATE_LINKS][3] = "Make    ~";
  130.     ui_commands[UI_STATE_LINKS][4] = "Return";
  131.     ui_commands[UI_STATE_LINKS][5] = "Quit";
  132.     ui_commands[UI_STATE_LINKS][6] = "Help";
  133.  
  134.     ui_commands[UI_STATE_FLAG][0] = "Safety";
  135.     ui_commands[UI_STATE_FLAG][1] = "Quit";
  136.     ui_commands[UI_STATE_FLAG][2] = "Help";
  137.  
  138.     ui_commands[UI_STATE_LINKS_MAKE][0] = "from Source unit  !";
  139.     ui_commands[UI_STATE_LINKS_MAKE][1] = "to Target unit    !";
  140.     ui_commands[UI_STATE_LINKS_MAKE][2] = "Clique";
  141.     ui_commands[UI_STATE_LINKS_MAKE][3] = "Inverse";
  142.     ui_commands[UI_STATE_LINKS_MAKE][4] = "Double";
  143.     ui_commands[UI_STATE_LINKS_MAKE][5] = "Return";
  144.     ui_commands[UI_STATE_LINKS_MAKE][6] = "Quit";
  145.     ui_commands[UI_STATE_LINKS_MAKE][7] = "Help";
  146.  
  147.     ui_commands[UI_STATE_UNITS_COPY][0] = "All";
  148.     ui_commands[UI_STATE_UNITS_COPY][1] = "Input";
  149.     ui_commands[UI_STATE_UNITS_COPY][2] = "Output";
  150.     ui_commands[UI_STATE_UNITS_COPY][3] = "None";
  151.     ui_commands[UI_STATE_UNITS_COPY][4] = "Structure  ~";
  152.     ui_commands[UI_STATE_UNITS_COPY][5] = "Return";
  153.     ui_commands[UI_STATE_UNITS_COPY][6] = "Quit";
  154.     ui_commands[UI_STATE_UNITS_COPY][7] = "Help";
  155.  
  156.     ui_commands[UI_STATE_UNITS_COPY_STRUCTURE][0] = "All";
  157.     ui_commands[UI_STATE_UNITS_COPY_STRUCTURE][1] = "Input";
  158.     ui_commands[UI_STATE_UNITS_COPY_STRUCTURE][2] = "Output";
  159.     ui_commands[UI_STATE_UNITS_COPY_STRUCTURE][3] = "None";
  160.     ui_commands[UI_STATE_UNITS_COPY_STRUCTURE][4] = "Back binding";
  161.     ui_commands[UI_STATE_UNITS_COPY_STRUCTURE][5] = "Forward binding";
  162.     ui_commands[UI_STATE_UNITS_COPY_STRUCTURE][6] = "Double binding";
  163.     ui_commands[UI_STATE_UNITS_COPY_STRUCTURE][7] = "Return";
  164.     ui_commands[UI_STATE_UNITS_COPY_STRUCTURE][8] = "Quit";
  165.     ui_commands[UI_STATE_UNITS_COPY_STRUCTURE][9] = "Help";
  166.  
  167.     ui_commands[UI_STATE_LINKS_COPY][0] = "All          T";
  168.     ui_commands[UI_STATE_LINKS_COPY][1] = "Input        T";
  169.     ui_commands[UI_STATE_LINKS_COPY][2] = "Output       T";
  170.     ui_commands[UI_STATE_LINKS_COPY][3] = "None         T";
  171.     ui_commands[UI_STATE_LINKS_COPY][4] = "Environment  T";
  172.     ui_commands[UI_STATE_LINKS_COPY][5] = "Return";
  173.     ui_commands[UI_STATE_LINKS_COPY][6] = "Quit";
  174.     ui_commands[UI_STATE_LINKS_COPY][7] = "Help";
  175.  
  176.     ui_commands[UI_STATE_LINKS_DELETE][0] = "from Source unit  !";
  177.     ui_commands[UI_STATE_LINKS_DELETE][1] = "to Target unit    !";
  178.     ui_commands[UI_STATE_LINKS_DELETE][2] = "Clique";
  179.     ui_commands[UI_STATE_LINKS_DELETE][3] = "Return";
  180.     ui_commands[UI_STATE_LINKS_DELETE][4] = "Quit";
  181.     ui_commands[UI_STATE_LINKS_DELETE][5] = "Help";
  182.  
  183.     ui_commands[UI_STATE_UNITS_SET][ 0] = "Activation          T";
  184.     ui_commands[UI_STATE_UNITS_SET][ 1] = "Initial activation  T";
  185.     ui_commands[UI_STATE_UNITS_SET][ 2] = "Output              T";
  186.     ui_commands[UI_STATE_UNITS_SET][ 3] = "Bias                T";
  187.     ui_commands[UI_STATE_UNITS_SET][ 4] = "Name                T";
  188.     ui_commands[UI_STATE_UNITS_SET][ 5] = "io-Type             T";
  189.     ui_commands[UI_STATE_UNITS_SET][ 6] = "Default io-type";
  190.     ui_commands[UI_STATE_UNITS_SET][ 7] = "Layers";
  191.     ui_commands[UI_STATE_UNITS_SET][ 8] = "Function            ~";
  192.     ui_commands[UI_STATE_UNITS_SET][ 9] = "Return";
  193.     ui_commands[UI_STATE_UNITS_SET][10] = "Quit";
  194.     ui_commands[UI_STATE_UNITS_SET][11] = "Help";
  195.  
  196.     ui_commands[UI_STATE_UNITS_SET_FUNCTION][0] = "Activation func";
  197.     ui_commands[UI_STATE_UNITS_SET_FUNCTION][1] = "Output func";
  198.     ui_commands[UI_STATE_UNITS_SET_FUNCTION][2] = "F-type";
  199.     ui_commands[UI_STATE_UNITS_SET_FUNCTION][3] = "Return";
  200.     ui_commands[UI_STATE_UNITS_SET_FUNCTION][4] = "Quit";
  201.     ui_commands[UI_STATE_UNITS_SET_FUNCTION][5] = "Help";
  202.  
  203.     ui_commands[UI_STATE_GRAPHIC][ 0] = "Origin     !";
  204.     ui_commands[UI_STATE_GRAPHIC][ 1] = "Move       T";
  205.     ui_commands[UI_STATE_GRAPHIC][ 2] = "All";
  206.     ui_commands[UI_STATE_GRAPHIC][ 3] = "Complete";
  207.     ui_commands[UI_STATE_GRAPHIC][ 4] = "Units";
  208.     ui_commands[UI_STATE_GRAPHIC][ 5] = "Links";
  209.     ui_commands[UI_STATE_GRAPHIC][ 6] = "Direction  !";
  210.     ui_commands[UI_STATE_GRAPHIC][ 7] = "Grid";
  211.     ui_commands[UI_STATE_GRAPHIC][ 8] = "Return";
  212.     ui_commands[UI_STATE_GRAPHIC][ 9] = "Quit";
  213.     ui_commands[UI_STATE_GRAPHIC][10] = "Help";
  214.  
  215.     ui_commands[UI_STATE_GETDEST][0] = "Return";
  216.     ui_commands[UI_STATE_GETDEST][1] = "Quit";
  217.  
  218.     ui_commands[UI_STATE_SITES][0] = "Add";
  219.     ui_commands[UI_STATE_SITES][1] = "Delete";
  220.     ui_commands[UI_STATE_SITES][2] = "Copy    ~";
  221.     ui_commands[UI_STATE_SITES][3] = "Quit";
  222.     ui_commands[UI_STATE_SITES][4] = "Help";
  223.  
  224.     ui_commands[UI_STATE_SITES_COPY][0] = "with No links";
  225.     ui_commands[UI_STATE_SITES_COPY][1] = "with All links";
  226.     ui_commands[UI_STATE_SITES_COPY][3] = "Quit";
  227.     ui_commands[UI_STATE_SITES_COPY][4] = "Help";
  228.  
  229.     ui_commands[UI_STATE_UNITS_3D][0] = "Z";
  230.     ui_commands[UI_STATE_UNITS_3D][1] = "Move";
  231.     ui_commands[UI_STATE_UNITS_3D][2] = "Quit";
  232.     ui_commands[UI_STATE_UNITS_3D][3] = "Help";
  233. }
  234.  
  235.  
  236. /*****************************************************************************
  237.   FUNCTION : ui_key_abortOutlineAction
  238.  
  239.   PURPOSE  : finish the current action (move or copy) with a outline of all
  240.              selected units
  241.   RETURNS  : void
  242.   NOTES    :
  243.  
  244.   UPDATE   : 20.9.1990
  245. ******************************************************************************/
  246.  
  247. static void ui_key_abortOutlineAction (void)
  248.  
  249. {
  250.     struct PosType offset;
  251.  
  252.     ui_outlineActive    = FALSE;
  253.  
  254.     /* erase outline */
  255.     offset.x = ui_key_eventPos.x - ui_targetUnit.gridPos.x;
  256.     offset.y = ui_key_eventPos.y - ui_targetUnit.gridPos.y;
  257.     ui_sel_drawBoxes(ui_currentDisplay, UI_GLOBAL, offset);
  258. }
  259.  
  260.  
  261. /*****************************************************************************
  262.   FUNCTION : ui_key_startOutlineAction
  263.  
  264.   PURPOSE  : start a action (move or copy) and draw a outline of all selected
  265.              units
  266.   RETURNS  : void
  267.   NOTES    :
  268.  
  269.   UPDATE   : 20.9.1990
  270. ******************************************************************************/
  271.  
  272. static void ui_key_startOutlineAction (void)
  273.  
  274. {
  275.     struct PosType offset;
  276.  
  277.     ui_key_currentState = UI_STATE_GETDEST;
  278.     ui_outlineActive    = TRUE;
  279.  
  280.     /* draw initial outline */
  281.     offset.x = ui_key_eventPos.x - ui_targetUnit.gridPos.x;
  282.     offset.y = ui_key_eventPos.y - ui_targetUnit.gridPos.y;
  283.     ui_sel_drawBoxes(ui_currentDisplay, UI_GLOBAL, offset);
  284. }
  285.  
  286.  
  287. /*****************************************************************************
  288.   FUNCTION : ui_key_automata
  289.  
  290.   PURPOSE  : The automata is realized in a big switch statement.
  291.              Further information: see ui_can_KEventProc
  292.   RETURNS  : void
  293.   NOTES    :
  294.  
  295.   UPDATE   : 20.9.1990
  296. ******************************************************************************/
  297.  
  298. static void ui_key_automata (struct Ui_DisplayType *displayPtr, 
  299.                 struct PosType eventPixPos, char key)
  300.  
  301. {
  302.     char            string[50];
  303.     char            prefix[25];
  304.  
  305.     ui_key_currentKey = key;
  306.     ui_key_eventPos   = ui_utilPixToGrid(displayPtr, eventPixPos);
  307.     ui_key_unitNo     =
  308.     krui_getUnitNoNearPosition(&ui_key_eventPos, 
  309.                    displayPtr->subNetNo,
  310.                    9, 
  311.                    displayPtr->gridSize);
  312.     ui_currentDisplay = displayPtr; /* for action routines */
  313.     
  314.     switch (ui_key_currentState) {
  315.  
  316.        /* ------------------------------------------------------------------- */
  317.     
  318.       case UI_START_STATE:
  319.     
  320.     switch (ui_key_currentKey) {
  321.       case 'f': /* Flags */
  322.         ui_key_currentState     = UI_STATE_FLAG; 
  323.         ui_key_returnFlagState  = UI_START_STATE;
  324.         break;
  325.       case 'm': /* Mode */
  326.         ui_key_currentState     = UI_STATE_MODE; 
  327.         break;
  328.       case 'u': /* Units */
  329.         ui_key_currentState     = UI_STATE_UNITS; 
  330.         ui_key_returnUnitState  = UI_START_STATE; /* return top level */
  331.         break;
  332.       case 'l': /* Links */
  333.         ui_key_currentState     = UI_STATE_LINKS; 
  334.         ui_key_returnLinkState  = UI_START_STATE; /* return top level */
  335.         break;
  336.       case 'g': /* Graphic */
  337.         ui_key_currentState     = UI_STATE_GRAPHIC;
  338.         break;
  339.       case 's': /* Sites */
  340.         ui_key_currentState     = UI_STATE_SITES;
  341.         break;
  342.       case 'h': /* Help */
  343.         sprintf(string,"HELP: Keyboard.");
  344.         ui_printMessage(string);
  345.         ui_displayHelp("* Keyboard");
  346.         break;
  347.       default:
  348.         ui_key_currentState     = UI_START_STATE; /* stay here */
  349.     }   
  350.     
  351.     break;
  352.     
  353.        /* ------------------------------------------------------------------- */
  354.     
  355.       case UI_STATE_MODE: 
  356.     
  357.     switch (ui_key_currentKey) {
  358.       case 'u': /* Units */
  359.         ui_key_currentState     = UI_STATE_UNITS; 
  360.         ui_key_returnUnitState  = UI_STATE_UNITS; /* stay UNITS mode */
  361.         break;
  362.       case 'l': /* Links */
  363.         ui_key_currentState     = UI_STATE_LINKS; 
  364.         ui_key_returnLinkState  = UI_STATE_LINKS; /* stay in LINK mode */
  365.         break;
  366.       case 'q': /* quit */
  367.         ui_key_currentState = UI_START_STATE;
  368.         break;
  369.       case 'h': /* help */
  370.         sprintf(string,"HELP: Mode.");
  371.         ui_printMessage(string);
  372.         ui_displayHelp("* Mode");
  373.         break;
  374.       default:
  375.         ui_key_currentState     = UI_STATE_MODE; /* stay here */
  376.     }
  377.     
  378.     break;
  379.  
  380.        /* ------------------------------------------------------------------- */
  381.  
  382.       case UI_STATE_UNITS: 
  383.     
  384.     switch (ui_key_currentKey) {
  385.       case 'c':
  386.         ui_key_currentState    = UI_STATE_UNITS_COPY; 
  387.         break;
  388.       case 's':
  389.         ui_key_currentState     = UI_STATE_UNITS_SET;
  390.         break;
  391.       case 'd':
  392.         ui_key_currentState     = ui_key_returnUnitState;
  393.         if (NOT ui_safetyFlg OR 
  394.         ui_confirmYes("Units Delete. Are you sure?")) {
  395.         sprintf(string,"Units Delete.");
  396.         ui_printMessage(string);
  397.         ui_can_setBusyCursor();
  398.         ui_action_unitsDelete();
  399.         ui_can_setNormalCursor();
  400.         }
  401.         break;
  402.       case 'i':
  403.         /* no message, because operation is very fast */
  404.         ui_key_currentState     = UI_STATE_UNITS_INSERT;
  405.         break;
  406.       case 'm':
  407.         sprintf(string,"Units Move.");
  408.         ui_printMessage(string);
  409.         ui_key_action = UI_ACTION_MOVE;
  410.         ui_key_startOutlineAction();
  411.         break;
  412.       case 'f': 
  413.         sprintf(string,"Units Freeze.");
  414.         ui_printMessage(string);
  415.         ui_key_currentState     = ui_key_returnUnitState;
  416.         ui_can_setBusyCursor();
  417.         ui_action_setUnitAttribute(UI_FREEZE);
  418.         ui_can_setNormalCursor();
  419.         break;
  420.       case 'u': 
  421.         sprintf(string,"Units Unfreeze.");
  422.         ui_printMessage(string);
  423.         ui_key_currentState     = ui_key_returnUnitState;
  424.         ui_can_setBusyCursor();
  425.         ui_action_setUnitAttribute(UI_UNFREEZE);
  426.         ui_can_setNormalCursor();
  427.         break;
  428.       case 'r': /* return */
  429.         ui_key_currentState     = UI_START_STATE; 
  430.         break;
  431.       case 'q': /* quit */
  432.         if (ui_key_returnUnitState != UI_STATE_UNITS) /* return top level */
  433.         ui_key_currentState = ui_key_returnUnitState;
  434.         break;
  435.       case 'h': /* help */
  436.         sprintf(string,"HELP: Units.");
  437.         ui_printMessage(string);
  438.         ui_displayHelp("* Units");
  439.         break;
  440.       case '3': 
  441.         ui_key_currentState    = UI_STATE_UNITS_3D; 
  442.         break;
  443.       default:
  444.         ui_key_currentState     = UI_STATE_UNITS; /* stay here */
  445.     }
  446.     break;
  447.  
  448.       /* ------------------------------------------------------------------- */
  449.  
  450.       case UI_STATE_UNITS_INSERT: 
  451.     
  452.     switch (ui_key_currentKey) {
  453.       case 'd': /* default unit */
  454.         ui_key_currentState = ui_key_returnUnitState;
  455.         ui_action_unitInsert(UI_INSERT_DEFAULT);
  456.         break;
  457.       case 't': /* target unit */
  458.         ui_key_currentState = ui_key_returnUnitState;
  459.         ui_action_unitInsert(UI_INSERT_TARGET);
  460.         break;
  461.       case 'f': /* ftype unit */
  462.         ui_key_currentState = ui_key_returnUnitState;
  463.         ui_action_unitInsert(UI_INSERT_FTYPE);
  464.         break;
  465.       case 'r': /* return */
  466.         ui_key_currentState     = UI_START_STATE; 
  467.         break;
  468.       case 'q': /* quit */
  469.         if (ui_key_returnUnitState != UI_STATE_UNITS) /* return top level */
  470.         ui_key_currentState = ui_key_returnUnitState;
  471.         break;
  472.       case 'h': /* help */
  473.         sprintf(string,"HELP: Units Insert.");
  474.         ui_printMessage(string);
  475.         ui_displayHelp("* Units Insert");
  476.         break;
  477.       default:
  478.         ui_key_currentState     = UI_STATE_UNITS_INSERT; /* stay here */
  479.     }
  480.     break;
  481.  
  482.        /* ------------------------------------------------------------------- */
  483.     
  484.       case UI_STATE_LINKS: 
  485.     
  486.     switch (ui_key_currentKey) {
  487.       case 'c':
  488.         ui_key_currentState    = UI_STATE_LINKS_COPY; 
  489.         break;
  490.       case 'd':
  491.         ui_key_currentState    = UI_STATE_LINKS_DELETE;
  492.         break;
  493.       case 'm':
  494.         ui_key_currentState = UI_STATE_LINKS_MAKE; 
  495.         break;
  496.       case 's': /* Links Set */
  497.         ui_key_currentState = ui_key_returnLinkState;
  498.         ui_can_setBusyCursor();
  499.         ui_action_linksSet();
  500.         ui_can_setNormalCursor();
  501.         break;
  502.       case 'r':
  503.         ui_key_currentState  = UI_START_STATE; 
  504.         break;
  505.       case 'q': /* quit */
  506.         ui_key_currentState = ui_key_returnLinkState;;
  507.         break;
  508.       case 'h': /* help */
  509.         sprintf(string,"HELP: Links."); 
  510.         ui_printMessage(string);
  511.         ui_displayHelp("* Links");
  512.         break;
  513.       default:
  514.         ui_key_currentState = UI_STATE_LINKS; /* stay here */
  515.     }
  516.     break;
  517.     
  518.        /* ------------------------------------------------------------------- */
  519.  
  520.       case UI_STATE_FLAG: 
  521.     
  522.     switch (ui_key_currentKey) {
  523.         
  524.       case 's': /* safety flag (confirm when destructive operation) */
  525.         ui_key_currentState = ui_key_returnFlagState;
  526.         ui_safetyFlg = (NOT ui_safetyFlg);
  527.         ui_stat_displayStatus(ui_key_eventPos);
  528.         break;
  529.         
  530.       case 'q': /* quit */
  531.         ui_key_currentState = ui_key_returnFlagState;
  532.         break;
  533.         
  534.       case 'h': /* help flags */
  535.         sprintf(string,"HELP: Flags.");
  536.         ui_printMessage(string);
  537.         ui_displayHelp("* Flags");
  538.         break;
  539.  
  540.       default:
  541.         ui_key_currentState     = UI_STATE_FLAG; /* stay here */
  542.     }
  543.     break;
  544.  
  545.      /* ------------------------------------------------------------------- */
  546.     
  547.       case UI_STATE_LINKS_MAKE: 
  548.     
  549.     switch (ui_key_currentKey) {
  550.       case 'h': /* help */
  551.         sprintf(string,"HELP: Links Make.");
  552.         ui_printMessage(string);
  553.         ui_displayHelp("* Links Make");
  554.         break;
  555.       case 'c':
  556.         sprintf(string,"Links Make Clique.");
  557.         ui_printMessage(string);
  558.         ui_key_currentState = ui_key_returnLinkState;
  559.         ui_can_setBusyCursor();
  560.         ui_action_linksMakeClique(UI_DRAW);
  561.         ui_can_setNormalCursor();
  562.         break;
  563.       case 'i':
  564.         if (NOT ui_safetyFlg OR
  565.         ui_confirmYes("Links Make Inverse. Are you sure?")) {
  566.         sprintf(string,"Links Make Inverse.");
  567.         ui_printMessage(string);
  568.         ui_key_currentState = ui_key_returnLinkState;
  569.         ui_can_setBusyCursor();
  570.         ui_action_linksMakeReverse();
  571.         ui_can_setNormalCursor();
  572.         }
  573.         break;
  574.       case 'd':
  575.         sprintf(string,"Links Make Double.");
  576.         ui_printMessage(string);
  577.         ui_key_currentState = ui_key_returnLinkState;
  578.         ui_can_setBusyCursor();
  579.         ui_action_linksMakeBidirectional();
  580.         ui_can_setNormalCursor();
  581.         break;
  582.       case 's':
  583.         sprintf(string,"Links Make to Source unit.");
  584.         ui_printMessage(string);
  585.         ui_key_currentState = ui_key_returnLinkState;
  586.         ui_can_setBusyCursor();
  587.         ui_action_linksMakeFromSourceUnit(UI_DRAW);
  588.         ui_can_setNormalCursor();
  589.         break;
  590.       case 't':
  591.         sprintf(string,"Links Make to Target unit.");
  592.         ui_printMessage(string);
  593.         ui_key_currentState = ui_key_returnLinkState;
  594.         ui_can_setBusyCursor();
  595.         ui_action_linksMakeToTargetUnit(UI_DRAW);
  596.         ui_can_setNormalCursor();
  597.         break;
  598.       case 'r':
  599.         ui_key_currentState = UI_START_STATE;
  600.         break;
  601.       case 'q': /* quit */
  602.         ui_key_currentState = ui_key_returnLinkState;;
  603.         break;
  604.       default:
  605.         ui_key_currentState     = UI_STATE_LINKS_MAKE; /* stay here */
  606.     }
  607.     break;
  608.     
  609.       /* ------------------------------------------------------------------- */
  610.   
  611.       case UI_STATE_UNITS_COPY: 
  612.  
  613.  
  614.     switch (ui_key_currentKey) {
  615.       case 'q': /* quit */
  616.         ui_key_currentState = ui_key_returnUnitState;
  617.         break;
  618.       case 'h': /* help */
  619.         sprintf(string,"HELP: Units Copy.");
  620.         ui_printMessage(string);
  621.         ui_displayHelp("* Units Copy");
  622.         break; 
  623.       case 'a':
  624.         ui_key_linksToHandle = UI_ALL;
  625.         sprintf(string,"Units Copy All.");
  626.         ui_printMessage(string);
  627.         ui_key_action = UI_ACTION_COPY;
  628.         ui_key_startOutlineAction();
  629.         break;
  630.       case 'i':
  631.         ui_key_linksToHandle = UI_INPUT;
  632.         sprintf(string,"Units Copy Input.");
  633.         ui_printMessage(string);
  634.         ui_key_action = UI_ACTION_COPY;
  635.         ui_key_startOutlineAction();
  636.         break;
  637.       case 'o':
  638.         ui_key_linksToHandle = UI_OUT;
  639.         sprintf(string,"Units Copy Output.");
  640.         ui_printMessage(string);
  641.         ui_key_action = UI_ACTION_COPY;
  642.         ui_key_startOutlineAction();
  643.         break;
  644.       case 'n': /* without copying any links */
  645.         ui_key_linksToHandle = UI_NO_FLAG;
  646.         sprintf(string,"Units Copy None.");
  647.         ui_printMessage(string);
  648.         ui_key_action = UI_ACTION_COPY;
  649.         ui_key_startOutlineAction();
  650.         break;
  651.       case 's': /* structureCopy */
  652.         ui_key_currentState  = UI_STATE_UNITS_COPY_STRUCTURE;
  653.         ui_key_linksToHandle = UI_NO_FLAG;
  654.         break;
  655.       case 'r':
  656.         ui_key_currentState  = UI_START_STATE; 
  657.         break;
  658.       default:
  659.         ui_key_currentState   = UI_STATE_UNITS_COPY; /* stay here */
  660.     }
  661.     break;
  662.  
  663.       /* ------------------------------------------------------------------- */
  664.   
  665.       case UI_STATE_UNITS_COPY_STRUCTURE: 
  666.     
  667.     if (ui_key_currentKey != 'h') {
  668.         ui_key_currentState = ui_key_returnUnitState;
  669.     }    
  670.     
  671.     switch (ui_key_currentKey) {
  672.       case 'q': /* quit */
  673.         break;
  674.       case 'h': /* help */
  675.         sprintf(string,"HELP: Units Copy Structure.");
  676.         ui_printMessage(string);
  677.         ui_displayHelp("* Units Copy Structure");
  678.         break;
  679.       case 'a':
  680.         sprintf(string,"Units Copy Structure All.");
  681.         ui_printMessage(string);
  682.         ui_key_linksToHandle = UI_STRUCTURE_COPY + UI_ALL;
  683.         ui_key_action = UI_ACTION_COPY;
  684.         ui_key_startOutlineAction();
  685.         break;
  686.       case 'i':
  687.         ui_key_linksToHandle = UI_STRUCTURE_COPY + UI_INPUT;
  688.         sprintf(string,"Units Copy Structure Input.");
  689.         ui_printMessage(string);
  690.         ui_key_action = UI_ACTION_COPY;
  691.         ui_key_startOutlineAction();
  692.         break;
  693.       case 'o':
  694.         ui_key_linksToHandle = UI_STRUCTURE_COPY + UI_OUT;
  695.         sprintf(string,"Units Copy Structure Output.");
  696.         ui_printMessage(string);
  697.         ui_key_action = UI_ACTION_COPY;
  698.         ui_key_startOutlineAction();
  699.         break;
  700.       case 'n': /* without copying any links */
  701.         ui_key_linksToHandle = UI_STRUCTURE_COPY + UI_NO_FLAG;
  702.         sprintf(string,"Units Copy Structure None.");
  703.         ui_printMessage(string);
  704.         ui_key_action = UI_ACTION_COPY;
  705.         ui_key_startOutlineAction();
  706.         break;
  707.       case 'b': /* with back binding */
  708.         ui_key_linksToHandle = UI_STRUCTURE_COPY + UI_BACKWARD_BINDING;
  709.         sprintf(string,"Units Copy Structure Back.");
  710.         ui_printMessage(string);
  711.         ui_key_action = UI_ACTION_COPY;
  712.         ui_key_startOutlineAction();
  713.         break;
  714.       case 'f': /* with forward binding */
  715.         ui_key_linksToHandle = UI_STRUCTURE_COPY + UI_FORWARD_BINDING;
  716.         sprintf(string,"Units Copy Structure Forward.");
  717.         ui_printMessage(string);
  718.         ui_key_action = UI_ACTION_COPY;
  719.         ui_key_startOutlineAction();
  720.         break;
  721.       case 'd': /* with two-way binding (bidirectional) */
  722.         ui_key_linksToHandle = UI_STRUCTURE_COPY + UI_TWOWAY_BINDING;
  723.         sprintf(string,"Units Copy Structure Double.");
  724.         ui_printMessage(string);
  725.         ui_key_startOutlineAction();
  726.         ui_key_action = UI_ACTION_COPY;
  727.         break;
  728.       case 'r':
  729.         ui_key_currentState  = UI_START_STATE; 
  730.         break;
  731.       default:
  732.         ui_key_currentState  = UI_STATE_UNITS_COPY_STRUCTURE; 
  733.         /* stay here */
  734.     }
  735.     break;
  736.  
  737.        /* ------------------------------------------------------------------- */
  738.  
  739.       case UI_STATE_LINKS_COPY: 
  740.  
  741.  
  742.     if (ui_key_currentKey != 'h') {
  743.         ui_key_currentState = ui_key_returnLinkState;
  744.     }    
  745.  
  746.     
  747.     switch (ui_key_currentKey) /* */  {
  748.       case 'q': /* quit */
  749.         break;
  750.       case 'h': /* help */
  751.         sprintf(string,"HELP: Links Copy.");
  752.         ui_printMessage(string);
  753.         ui_displayHelp("* Links Copy");
  754.         break;
  755.       case 'e':
  756.         ui_can_setBusyCursor();
  757.         ui_action_linksCopyEnvironment();
  758.         ui_can_setNormalCursor();
  759.         break;
  760.       case 'a':
  761.         ui_key_linksToHandle = UI_ALL;
  762.         ui_can_setBusyCursor();
  763.         ui_action_linksCopy();
  764.         ui_can_setNormalCursor();
  765.         break;
  766.       case 'i':
  767.         ui_key_linksToHandle = UI_INPUT;
  768.         ui_can_setBusyCursor();
  769.         ui_action_linksCopy();
  770.         ui_can_setNormalCursor();
  771.         break;
  772.       case 'o':
  773.         ui_key_linksToHandle = UI_OUT;
  774.         ui_can_setBusyCursor();
  775.         ui_action_linksCopy();
  776.         ui_can_setNormalCursor();
  777.         break;
  778.       case 'n':
  779.         ui_key_linksToHandle = UI_NO_FLAG;
  780.         ui_can_setBusyCursor();
  781.         ui_action_linksCopy();
  782.         ui_can_setNormalCursor();
  783.         break;
  784.       case 'r':
  785.         ui_key_currentState  = UI_START_STATE; 
  786.         break;
  787.       default:
  788.         ui_key_currentState  = UI_STATE_LINKS_COPY; /* stay here */
  789.     }
  790.     break;
  791.  
  792.  
  793.        /* ------------------------------------------------------------------- */
  794.   
  795.       case UI_STATE_LINKS_DELETE: 
  796.  
  797.     if (ui_key_currentKey != 'h') {
  798.         ui_key_currentState = ui_key_returnLinkState;
  799.     }    
  800.     
  801.     switch (ui_key_currentKey) /* */  {
  802.       case 'q': /* quit */
  803.         break;
  804.       case 'h': /* help */
  805.         sprintf(string,"HELP: Links Delete.");
  806.         ui_printMessage(string);
  807.         ui_displayHelp("* Links Delete");
  808.         break;
  809.       case 'c':
  810.         if (NOT ui_safetyFlg OR 
  811.         ui_confirmYes("Links Delete Clique. Are you sure?")) {
  812.         ui_can_setBusyCursor();
  813.         ui_action_linksMakeClique(UI_ERASE);
  814.         ui_can_setNormalCursor();
  815.         }
  816.         break;
  817.       case 's':
  818.         if (NOT ui_safetyFlg OR 
  819.         ui_confirmYes("Links Delete from Source unit. Are you sure?")) {
  820.         ui_can_setBusyCursor();
  821.         ui_action_linksMakeFromSourceUnit(UI_ERASE);
  822.         ui_can_setNormalCursor();
  823.         }
  824.         break;
  825.       case 't':
  826.         if (NOT ui_safetyFlg OR
  827.         ui_confirmYes("Links Delete from Target unit. Are you sure?")) {
  828.         ui_can_setBusyCursor();
  829.         ui_action_linksMakeToTargetUnit(UI_ERASE);
  830.         ui_can_setNormalCursor();
  831.         }
  832.         break;
  833.       case 'r':
  834.         ui_key_currentState     = UI_START_STATE; 
  835.         break;
  836.       default:
  837.         ui_key_currentState     = UI_STATE_LINKS_DELETE; /* stay here */
  838.     }
  839.     break;
  840.  
  841.  
  842.      /* ------------------------------------------------------------------- */
  843.  
  844.       case UI_STATE_UNITS_SET:
  845.  
  846.     if (ui_key_currentKey != 'h') {
  847.         ui_key_currentState = ui_key_returnUnitState;
  848.     }    
  849.  
  850.     switch (ui_key_currentKey) /* */  {
  851.       case 'q': /* quit */
  852.         break;
  853.       case 'h': /* help */
  854.         sprintf(string,"HELP: Units Set.");
  855.         ui_printMessage(string);
  856.         ui_displayHelp("* Units Set");
  857.         break;
  858.       case 'n': /* name */
  859.         sprintf(string,"Units Set Name.");
  860.         ui_printMessage(string);
  861.         ui_can_setBusyCursor();
  862.         ui_action_setUnitAttribute(UI_SET_NAME);
  863.         ui_can_setNormalCursor();
  864.         break;
  865.       case 't': /* type */
  866.         sprintf(string,"Units Set io-Type.");
  867.         ui_printMessage(string);
  868.         ui_can_setBusyCursor();
  869.         ui_action_setUnitAttribute(UI_SET_IOTYPE);
  870.         ui_can_setNormalCursor();
  871.         break;
  872.       case 'd': /* Default type */
  873.         sprintf(string,"Units Set Default io-type.");
  874.         ui_printMessage(string);
  875.         ui_can_setBusyCursor();
  876.         ui_action_unitSetDefaultType();
  877.         ui_can_setNormalCursor();
  878.         break;
  879.       case 'a': /* activation */
  880.         sprintf(string,"Units Set Activation.");
  881.         ui_printMessage(string);
  882.         ui_can_setBusyCursor();
  883.         ui_action_setUnitAttribute(UI_SET_ACT);
  884.         ui_can_setNormalCursor();
  885.         break;
  886.       case 'b': /* bias */
  887.         sprintf(string,"Units Set Bias.");
  888.         ui_printMessage(string);
  889.         ui_can_setBusyCursor();
  890.         ui_action_setUnitAttribute(UI_SET_BIAS);
  891.         ui_can_setNormalCursor();
  892.         break;
  893.       case 'f': /* function ... */
  894.         ui_key_currentState = UI_STATE_UNITS_SET_FUNCTION;
  895.         break;
  896.       case 'i': /* initial activation */
  897.         sprintf(string,"Units Set Initial activation.");
  898.         ui_printMessage(string);
  899.         ui_can_setBusyCursor();
  900.         ui_action_setUnitAttribute(UI_SET_I_ACT);
  901.         ui_can_setNormalCursor();
  902.         break;
  903.       case 'o': /* output */
  904.         sprintf(string,"Units Set Output.");
  905.         ui_printMessage(string);
  906.         ui_can_setBusyCursor();
  907.         ui_action_setUnitAttribute(UI_SET_OUT);
  908.         ui_can_setNormalCursor();
  909.         break;
  910.       case 'l': /* layers */
  911.         sprintf(string,"Units Set Layers.");
  912.         ui_printMessage(string);
  913.         ui_can_setBusyCursor();
  914.         ui_action_setUnitLayers();
  915.         ui_can_setNormalCursor();
  916.         break;
  917.       case 'r':
  918.         ui_key_currentState     = UI_START_STATE; 
  919.         break;
  920.       default:
  921.         ui_key_currentState     = UI_STATE_UNITS_SET; 
  922.         break;
  923.     }
  924.     break;
  925.  
  926.       /* ------------------------------------------------------------------- */
  927.  
  928.       case UI_STATE_UNITS_SET_FUNCTION:
  929.  
  930.     if (ui_key_currentKey != 'h') {
  931.         ui_key_currentState = ui_key_returnUnitState;
  932.     }    
  933.     
  934.     switch (ui_key_currentKey) /* */  {
  935.       case 'q': /* quit */
  936.         break;
  937.       case 'h': /* help */
  938.         sprintf(string,"HELP: Units Set Function.");
  939.         ui_printMessage(string);
  940.         ui_displayHelp("* Units Set Function");
  941.         break;
  942.       case 'r':
  943.         ui_key_currentState     = UI_START_STATE; 
  944.         break;
  945.       case 'a': /* activation */
  946.         sprintf(string,"Units Set Activation function.");
  947.         ui_printMessage(string);
  948.         ui_can_setBusyCursor();
  949.         ui_action_setUnitAttribute(UI_SET_ACT_FUNC);
  950.         ui_can_setNormalCursor();
  951.         break;
  952.       case 'f': /* ftype */
  953.         sprintf(string,"Units Set Function Ftype.");
  954.         ui_printMessage(string);
  955.         ui_can_setBusyCursor();
  956.         ui_action_setUnitAttribute(UI_SET_FTYPE);
  957.         ui_can_setNormalCursor();
  958.         break;
  959.       case 'o': /* output */
  960.         sprintf(string,"Units Set Output function.");
  961.         ui_printMessage(string);
  962.         ui_can_setBusyCursor();
  963.         ui_action_setUnitAttribute(UI_SET_OUT_FUNC);
  964.         ui_can_setNormalCursor();
  965.         break;
  966.       default:
  967.         ui_key_currentState = UI_STATE_UNITS_SET_FUNCTION; /* stay here */
  968.     }
  969.     break;
  970.  
  971.       /* ------------------------------------------------------------------- */
  972.  
  973.       case UI_STATE_GRAPHIC:
  974.  
  975.     switch (ui_key_currentKey) {
  976.  
  977.       case 'q': /* quit */
  978.         ui_key_currentState = UI_START_STATE;
  979.         break;
  980.  
  981.       case 'h': /* help flags */
  982.         sprintf(string,"HELP: Graphics.");
  983.         ui_printMessage(string);
  984.         ui_displayHelp("* Graphic");
  985.         break;
  986.  
  987.       case 'o':
  988.         sprintf(string,"Graphics Origin.");
  989.         ui_printMessage(string);
  990.         displayPtr->origin = ui_key_eventPos;
  991.         ui_net_completeRefresh(displayPtr, UI_LOCAL);
  992.         ui_key_currentState = UI_START_STATE;
  993.         break;
  994.  
  995.       case 'm':
  996.         sprintf(string,"Graphics Move.");
  997.         ui_printMessage(string);
  998.         displayPtr->origin.x += 
  999.         ui_targetUnit.gridPos.x - ui_key_eventPos.x;
  1000.         displayPtr->origin.y += 
  1001.         ui_targetUnit.gridPos.y - ui_key_eventPos.y;
  1002.         ui_net_completeRefresh(displayPtr, UI_LOCAL);
  1003.         ui_key_currentState = UI_START_STATE;
  1004.         break;
  1005.  
  1006.       case 'u':
  1007.         sprintf(string,"Graphic Units.");
  1008.         ui_printMessage(string);
  1009.         ui_sel_reshowItems(ui_currentDisplay, UI_LOCAL);
  1010.         ui_net_updateWhole(displayPtr, UI_LOCAL, 
  1011.                    UI_DRAW_UNITS, UI_DRAW);
  1012.         ui_sel_reshowItems(ui_currentDisplay, UI_LOCAL);
  1013.         ui_key_currentState = UI_START_STATE;
  1014.         break;
  1015.  
  1016.       case 'l':
  1017.         sprintf(string,"Graphics Links.");
  1018.         ui_printMessage(string);
  1019.         ui_sel_reshowItems(ui_currentDisplay, UI_LOCAL);
  1020.         ui_net_updateWhole(displayPtr, UI_LOCAL, 
  1021.                    UI_DRAW_LINKS, UI_DRAW);
  1022.         ui_sel_reshowItems(ui_currentDisplay, UI_LOCAL);
  1023.         ui_key_currentState = UI_START_STATE;
  1024.         break;
  1025.  
  1026.       case 'a':
  1027.         sprintf(string,"Graphics All.");
  1028.         ui_printMessage(string);
  1029.         /* Don't erase the markers, because ui_net_completeRefresh()
  1030.            already erases the whole graphic area! The routine will draw
  1031.            the markers again by itsself, if neccessary! */
  1032.         ui_net_completeRefresh(displayPtr, UI_LOCAL);
  1033.         ui_key_currentState = UI_START_STATE;
  1034.         break;
  1035.  
  1036.       case 'c':
  1037.         sprintf(string,"Graphics Complete.");
  1038.         ui_printMessage(string);
  1039.         /* Don't erase the markers, because ui_net_completeRefresh()
  1040.            already erases the whole graphic area! The routine will draw
  1041.            the markers again by itsself, if neccessary! */
  1042.         ui_net_completeRefresh(displayPtr, UI_GLOBAL);
  1043.         ui_key_currentState = UI_START_STATE;
  1044.         break;
  1045.  
  1046.       case 'd':
  1047.         sprintf(string,"Graphics Direction.");
  1048.         ui_printMessage(string);
  1049.         ui_action_graphicsDirection();
  1050.         ui_key_currentState = UI_START_STATE;
  1051.         break;
  1052.  
  1053.       case 'g':
  1054.         sprintf(string,"Graphics Grid.");
  1055.         ui_printMessage(string);
  1056.         ui_action_graphicsGrid();
  1057.         ui_key_currentState = UI_START_STATE;
  1058.         break;
  1059.       case 'r':
  1060.         ui_key_currentState     = UI_START_STATE; 
  1061.         break;
  1062.       default:
  1063.         ui_key_currentState     = UI_STATE_GRAPHIC; /* stay here */
  1064.     }
  1065.     break;
  1066.  
  1067.       /* ------------------------------------------------------------------- */
  1068.  
  1069.       case UI_STATE_GETDEST:
  1070.  
  1071.     switch (ui_key_currentKey) {
  1072.  
  1073.       case 'r': /* quit */
  1074.         ui_key_currentState = UI_START_STATE;
  1075.         ui_key_abortOutlineAction();
  1076.         break;
  1077.       case 'q': /* quit */
  1078.         ui_key_currentState = ui_key_returnUnitState;
  1079.         ui_key_abortOutlineAction();
  1080.         break;
  1081.       default:
  1082.         ui_key_currentState     = UI_STATE_GETDEST; /* stay here */
  1083.     }
  1084.     break;
  1085.  
  1086.       /* ------------------------------------------------------------------- */
  1087.  
  1088.       case UI_STATE_SITES:
  1089.  
  1090.     switch (ui_key_currentKey) {
  1091.  
  1092.       case 'h': /* help */
  1093.         sprintf(string,"HELP: Sites.");
  1094.         ui_printMessage(string);
  1095.         ui_displayHelp("* Site");
  1096.         break;
  1097.       case 'q': /* quit */
  1098.         ui_key_currentState     = UI_START_STATE;
  1099.         break;
  1100.       case 'a': /* add */
  1101.         ui_key_currentState     = UI_START_STATE;
  1102.         ui_action_sitesMake(UI_DRAW);
  1103.         break;
  1104.       case 'd': /* delete */
  1105.         if (NOT ui_safetyFlg OR
  1106.         ui_confirmYes("Sites Delete. Are you sure?")) {
  1107.         ui_key_currentState     = UI_START_STATE; 
  1108.         ui_action_sitesMake(UI_ERASE);
  1109.         }
  1110.         break;
  1111.       case 'c': /* copy */
  1112.         ui_key_currentState     = UI_STATE_SITES_COPY; 
  1113.         break;
  1114.       default:
  1115.         ui_key_currentState     = UI_STATE_SITES; /* stay here */
  1116.     }
  1117.     break;
  1118.  
  1119.       /* ------------------------------------------------------------------- */
  1120.  
  1121.       case UI_STATE_SITES_COPY:
  1122.  
  1123.     switch (ui_key_currentKey) {
  1124.  
  1125.       case 'h': /* help */
  1126.         sprintf(string,"HELP: Sites Copy.");
  1127.         ui_printMessage(string);
  1128.         ui_displayHelp("* Sites Copy");
  1129.         break;
  1130.       case 'q': /* quit */
  1131.         ui_key_currentState     = UI_START_STATE;
  1132.         break;
  1133.       case 'a': /* with all links */
  1134.         ui_key_currentState     = UI_START_STATE;
  1135.         ui_key_linksToHandle = UI_ALL;
  1136.         ui_action_sitesCopy();
  1137.         break;
  1138.       case 'n': /* with no links */
  1139.         ui_key_currentState     = UI_START_STATE; 
  1140.         ui_key_linksToHandle = UI_NO_FLAG;
  1141.         ui_action_sitesCopy();
  1142.         break;
  1143.       default:
  1144.         ui_key_currentState     = UI_STATE_SITES; /* stay here */
  1145.     }
  1146.         break;
  1147.  
  1148.      /* ------------------------------------------------------------------- */
  1149.      /* ------------------------------------------------------------------- */
  1150.  
  1151.       case UI_STATE_UNITS_3D:
  1152.  
  1153.     switch (ui_key_currentKey) {
  1154.  
  1155.       case 'z': /* z-value */
  1156.         ui_key_currentState     = UI_START_STATE;
  1157.             ui_action_UnitZcoordinate ();
  1158.         break;
  1159.       case 'm': /* move */
  1160.         ui_key_currentState     = UI_START_STATE;
  1161.             ui_action_UnitZsetReference ();
  1162.         break;
  1163.       case 'h': /* help */
  1164.         break;
  1165.       case 'q': /* quit */
  1166.         ui_key_currentState     = UI_START_STATE;
  1167.         break;
  1168.       default:
  1169.         ui_key_currentState     = UI_STATE_SITES; /* stay here */
  1170.     }
  1171.         break;
  1172.     }
  1173.  
  1174.     sprintf(string,"");
  1175.  
  1176.     switch (ui_key_currentState) {
  1177.       case UI_START_STATE: 
  1178.     sprintf(prefix,"");
  1179.     break;
  1180.       case UI_STATE_MODE: 
  1181.     sprintf(prefix,"Mode");
  1182.     break;
  1183.       case UI_STATE_UNITS: 
  1184.     sprintf(prefix,"Units");
  1185.     break;
  1186.       case UI_STATE_LINKS: 
  1187.     sprintf(prefix,"Links");
  1188.     break;
  1189.       case UI_STATE_FLAG: 
  1190.     sprintf(prefix,"Flag");
  1191.     break;
  1192.       case UI_STATE_LINKS_MAKE: 
  1193.     sprintf(prefix,"Links Make");
  1194.     break;
  1195.       case UI_STATE_UNITS_INSERT: 
  1196.     sprintf(prefix,"Units Insert");
  1197.     break;
  1198.       case UI_STATE_UNITS_COPY: 
  1199.     sprintf(prefix,"Units Copy");
  1200.     break;
  1201.       case UI_STATE_UNITS_COPY_STRUCTURE:
  1202.     sprintf(prefix,"Units Copy Structure");
  1203.     break;
  1204.        case UI_STATE_UNITS_3D:
  1205.     sprintf(prefix,"Units 3D");
  1206.     break;
  1207.       case UI_STATE_LINKS_COPY: 
  1208.     sprintf(prefix,"Links Copy");
  1209.     break;
  1210.       case UI_STATE_LINKS_DELETE: 
  1211.     sprintf(prefix,"Links Delete");
  1212.     break;
  1213.       case UI_STATE_UNITS_SET: 
  1214.     sprintf(prefix,"Units Set");
  1215.     break;
  1216.       case UI_STATE_UNITS_SET_FUNCTION: 
  1217.     sprintf(prefix,"Units Set Function");
  1218.     break;
  1219.       case UI_STATE_GRAPHIC:
  1220.     sprintf(prefix,"Graphic");
  1221.     break;
  1222.       case UI_STATE_SITES:
  1223.     sprintf(prefix,"Sites");
  1224.     break;
  1225.       case UI_STATE_SITES_COPY:
  1226.     sprintf(prefix,"Sites Copy");
  1227.     break;
  1228.     }
  1229.     if (ui_key_currentState == UI_STATE_GETDEST)
  1230.     sprintf(string,"click on destination with left button");
  1231.     else
  1232.     sprintf(string,"%s>",prefix);
  1233.     ui_printMessage(string);
  1234. }
  1235.  
  1236.  
  1237. /*****************************************************************************
  1238.   FUNCTION : ui_can_KEventProc
  1239.  
  1240.   PURPOSE  : This routine accepts all valid key sequences. Its basic mechanism
  1241.              is a finite automaton with 8 states. On each ASCII_EVENT for the
  1242.          canvas, 
  1243.   RETURNS  : - alteration of network and graphic via editor commands
  1244.              - alteration of status info
  1245.          - alteration of units info panel via 
  1246.            ui_info_makeUnitInfoPanelConsistent()
  1247.   NOTES    : The automat changes his behaviour in dependency of the variables:
  1248.              - ui_key_unitsReturnState
  1249.          - ui_key_linksReturnState
  1250.          which are set by the commands "Mode Units" and "Mode Links" and
  1251.          the command "... Return" implicitly.
  1252.  
  1253.   UPDATE   :    
  1254. *****************************************************************************/
  1255.  
  1256. void ui_can_KEventProc (Widget w, struct Ui_DisplayType *displayPtr, XEvent *event)
  1257.  
  1258. {
  1259.     char            string[50];
  1260.     struct PosType  eventPixPos;
  1261.     KeySym          key;
  1262.  
  1263.     if (displayPtr->frozen) return; /* don't accept this event here */
  1264.     
  1265.     if (event->type != KeyPress)
  1266.     return;
  1267.     
  1268.     XLookupString((XKeyEvent *) event, string, 1, &key, NULL);
  1269.  
  1270.     if( (key == XK_Control_L) OR (key == XK_Control_R))
  1271.     return;
  1272.  
  1273.     if ((string[0] < '3') OR ((string[0] > '3') AND (string[0] < 'a')) 
  1274.       OR (string[0] > 'z'))
  1275.     return;
  1276.  
  1277.     eventPixPos.x     = (int) event->xkey.x;
  1278.     eventPixPos.y     = (int) event->xkey.y;
  1279.    
  1280.     ui_key_automata(displayPtr, eventPixPos, string[0]);
  1281. }
  1282.  
  1283.  
  1284. /*****************************************************************************
  1285.   FUNCTION : ui_key_menuCallback
  1286.  
  1287.   PURPOSE  : callback. Called when a menu item was selected
  1288.   RETURNS  : void
  1289.   NOTES    : 
  1290.  
  1291.   UPDATE   : 20.9.1990
  1292. ******************************************************************************/
  1293.  
  1294. static void ui_key_menuCallback (Widget w, int key, caddr_t call_data)
  1295.  
  1296. {
  1297.     ui_key_automata(ui_currentDisplay, ui_pixPosMouse, (char) key);
  1298. }
  1299.  
  1300.  
  1301. /*****************************************************************************
  1302.   FUNCTION : ui_key_menuPopdownCallback
  1303.  
  1304.   PURPOSE  : finish the menu
  1305.   RETURNS  :
  1306.   NOTES    : it is neccessary to destroy the menu widget, otherwise the new
  1307.              menu will be added to the widget tree, but not be shown!!
  1308.  
  1309.   UPDATE   : 20.9.1990
  1310. ******************************************************************************/
  1311.  
  1312. static void ui_key_menuPopdownCallback (Widget w, caddr_t client_data, 
  1313.                     caddr_t call_data)
  1314.  
  1315. {
  1316.     XtDestroyWidget(ui_key_menu);
  1317. }
  1318.  
  1319.  
  1320. /*****************************************************************************
  1321.   FUNCTION : ui_key_popMenu
  1322.  
  1323.   PURPOSE  : show the menu
  1324.   RETURNS  : void
  1325.   NOTES    :
  1326.  
  1327.   UPDATE   : 20.9.1990
  1328. ******************************************************************************/
  1329.  
  1330. void ui_key_popMenu (struct Ui_DisplayType *displayPtr)
  1331.  
  1332. {
  1333.     Widget         mItem;
  1334.     int            i = 0;
  1335.     int            j;
  1336.       
  1337.     ui_key_menu = 
  1338.     XtCreatePopupShell("popmenu", simpleMenuWidgetClass, 
  1339.                displayPtr->widget, NULL, 0);
  1340.     XtAddCallback(ui_key_menu, XtNpopdownCallback,
  1341.           (XtCallbackProc) ui_key_menuPopdownCallback, NULL);
  1342.     
  1343.     while (ui_commands[ui_key_currentState][i] != NULL) {
  1344.     mItem =
  1345.         XtCreateManagedWidget(ui_commands[ui_key_currentState][i],
  1346.                   smeBSBObjectClass, ui_key_menu, NULL, 0);
  1347.  
  1348.     j = 0;
  1349.     while ((((ui_commands[ui_key_currentState][i])[j] < 'A') OR
  1350.         ((ui_commands[ui_key_currentState][i])[j] > 'Z')) AND
  1351.            (ui_commands[ui_key_currentState][i])[j] != '\0') 
  1352.         j++;
  1353.  
  1354.     if ((ui_commands[ui_key_currentState][i])[j] != '\0') {
  1355.         XtAddCallback(mItem, XtNcallback, (XtCallbackProc) ui_key_menuCallback, (caddr_t) ((ui_commands[ui_key_currentState][i])[j] + 32));
  1356.     }    
  1357.     i++;
  1358.     }
  1359. }
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365. /* end of file */
  1366. /* lines: 1399 */
  1367.  
  1368.  
  1369.  
  1370.  
  1371.